import time
import random


# Background intro
def Background():
    print("You are in a land full of dragons. In front of you,")
    print('you see two caves. In one cave, the dragon is friendly')
    print('and will share his treasure with you. The other dragon')
    print('is greedy and hungry, and will eat you on sight.')
    print()


# chooseCave
def chooseCave():
    cave = ''
    print('Which cave will you go into? (1 or 2)')
    cave = int(input())
    return cave

# checkCave


def checkCave(chooseCave):
    print('You approach the cave,')
    time.sleep(2)
    print('It is dark and spooky...')
    time.sleep(2)
    print('A large dragon jumps out in front of you! He opens his jaws and...')
    time.sleep(2)
    print()
    time.sleep(2)

    friendlyCave = random.randint(1, 2)
    if friendlyCave == chooseCave:
        print('Gives you his treasure!')
    else:
        print('Gobbles you down in one bite!')

playAgain = 'yes'
while playAgain == 'yes' or playAgain == 'y':
    Background()
    number = chooseCave()#
    checkCave(number)
    print('Do you want to play again? (yes or no)')
    playAgain = input()
'''
再次运行报错:
如果这么写:chooseCave = chooseCave()
	Traceback (most recent call last):
  File "/Users/vincent/pyGame/Dragon Realm.py", line 42, in <module>
    chooseCave = chooseCave()
    当执行完这一步以后, chooseCave 已经变成了函数了,不再是chooseCave 返回的变量值
TypeError: 'int' object is not callable
'''
    
